function [ktp1,v] = find_val(k0,kt,vlast,delta, theta,beta)
[ktp1,v]=fminbnd(@valfun,0.01,6.2);

function val=valfun(k)
 g=interp1(k0,vlast,k,'linear');
 kk=kt^theta-k+(1-delta)*kt;
 if kk<=0
     val=-888-800*abs(kk);
 else
     val=log(kk)+beta*g;
 end
 val=-val;
end
end